<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="leagal_aid.bean.*,java.util.*,java.io.*"%>

<%@page import="java.text.SimpleDateFormat"%>

<%
	Date d = new Date();
	SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
	String now = df.format(d);
	/* String lb = request.getParameter("category");
	session.setAttribute("category", lb); */
	//String lb = session.getAttribute("ca")
	String username=null;
	if(session.getAttribute("username")==null || session.getAttribute("username").equals("")){
		response.setCharacterEncoding("utf-8");
		PrintWriter pout = response.getWriter();
		pout.print("<script>alert('请先登录'); window.location='../login.jsp' </script>");
		pout.flush();
		pout.close();
	}
	else{
		username = session.getAttribute("username").toString();
	}
%>


<!DOCTYPE html>
<html>

<head>
<style type="text/css">
table {
	margin-top: 5px;
	margin-bottom: 5px;
	width: 100%;
}

td {
	height: 35px;
}

.left {
	width: 12%;
	text-align: center;
	background-color: #e6f2fe;
}

.form {
	border-color: #acd0d0;
}
</style>
<meta charset="UTF-8">
<title>Insert title here</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../webupload/bootstrap/css/bootstrap.min.css"
	rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css"
	href="../webupload/webuploader.css">
<link rel="stylesheet" type="text/css" href="../webupload/style.css">
</head>

<body
	style="padding-left: 20px; padding-right: 20px; padding-bottom: 50px;">
	<input id="picture" style="display: none;" />
	<div class="abroad">
		<div class="within">
			<div>
				<table class="form" border="1" cellpadding="5" cellspacing="0">
					<tbody>
						 <tr>
							<td class="left">姓名：</td>
							<td><input type="text" id="name" value=""
									style="width: 60%; height: 30px; margin-left: 3px;">
							</td>
						
							<td class="left">发布时间：</td>
							<td><input type="date" id="txtDate" value="<%=now%>"
								style="font-size: 14px; font-family: 华文黑体; margin-left: 3px; height: 30px;"></td>
						</tr>
						 <tr>
							<td class="left">是否放在首页：</td>
							<td>
								<select name="select2" id="homepage" style="margin-left:3px; height:30px;width: 100px">
									<option value="1" selected="selected">是</option>
									<option value="0">否</option>
								</select>
							</td>
							<td class="left">*分类：</td>
							<td class="right" style="padding-left:3px;">
								<select id="category" name="channelId" value=""
									style="height: 30px; width: 40%;">
									<option value="team" class="sel-disabled">团队介绍</option>
								</select>
							</td>
						</tr>
						<tr>
							<td class="left">选择图片：</td>
							<td colspan="3">
								<div class="container">
									<div class="uploader uploader1">
										<div class="wrapper">
											<div class="file-list"></div>
										</div>
										<div class="actions-area">
											<div class="actions">
												<div class="filePicker action">选择图片</div>
												<button class="uploadFile action upload-btn disabled">上传图片</button>
											</div>
										</div>
									</div>
								</div>
							</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</div>
	<script id="container" type="text/plain" style="height: 400px;">
        </script>
	<div style="text-align: center;">
		<button id="submit" class="update_button">递交</button>
	</div>
	<script type="text/javascript" src="../ueditor/third-party/jquery-1.10.2.js"></script>
 <!-- 配置文件 -->
 <script type="text/javascript" src="../ueditor/ueditor.config.js"></script>
 <!-- 编辑器源码文件 -->
 <script type="text/javascript" src="../ueditor/ueditor.all.js"></script>
 <!-- 实例化编辑器 -->
 <script type="text/javascript">
	<!-- 实例化编辑器 -->
	
		var editor = UE.getEditor('container');
		$("#submit").click(function () {
			var data = editor.getContent();
        	var picture= $("#picture").val();
        	var txtDate = $("#txtDate").val();
        	var name = $("#name").val();
        	var homepage = $("#homepage").val();
        	var category = $("#category").val();
			$.ajax({
				cache: true,
				type: "post",
				url: "operating_team/doadd.jsp",
				data: {
					 data:data,
				     homepage:homepage,
				     txtDate: txtDate,
				     picture:picture,
				     name:name,
				     category:category,				     
				},
				async: false,
				error: function (request) {
					alert("Connection error");
				},
				success: function () {
					alert("success");
					window.location.href = "team_introduce.jsp";
				}
			});
		});
	</script>
	<script src="../webupload/jquery.min.js"></script>
	<!-- Include all compiled plugins (below), or include individual files as needed -->
	<script src="../webupload/bootstrap/js/bootstrap.min.js"></script>
	<script src="../webupload/webuploader.js"></script>
	<script src="../webupload/webuploader.support.js"></script>
	<script>
		var w1 = new WebUploaderSupport({
			server: "../FileUploadServlet",
			paste: document.body
			, swf: '/webuploader/Uploader.swf'  // swf文件所处路径
			, support: {
				uploader: ".uploader.uploader1",  //上传区域容器选择器
				fileSize: 1,  //文件总个数, -1时无限制
				/*  serverFiles: [
					 {"src":"../images/preview/1.jpg","name":"1.jpg","attrs":{"data-server-file":true,"data-delete-url":""}}
				 ],
	   */
				uploadSuccess: function (file, data) {
					var $item = this.getItem(file),
						$state = $item.find('.state');
					$item.find('.progress').hide();
					if (data.status) {  //上传成功时
						this.uploadSuccessCallbck($item, data);  //用于标识为服务端文件
						if (!$state.hasClass('success')) {
							$state.attr("class", "state success");
							$state.text('上传成功');
							$("#myimg").attr("src", data.path);
							$("#picture").attr("value", data.path);
							$item.attr("data-server-file", "true");
							$item.attr("data-delete-url", data.delurl);
							alert(data.delurl);
						}
						$item.removeClass("retry");
					} else {
						if (!$state.hasClass('error')) {
							$state.attr("class", "state error");
							$state.text('上传失败');
						}
						$item.addClass("retry");
					}
				},

				deleteServerFile: function ($item, url, deleteServerFileCallback) {
					var self = this;
					$.ajax({
						dataType: "json",
						type: "post",
						url: "../" + url,
						success: function (json) {
							deleteServerFileCallback(self, $item, json);  //通过callback执行业务操作
							//文件操作完成后重新加载选择按钮样式
							self.loadChooseFileBtnStyle();
							$("#myimg").attr("src", "");
							$("#picture").attr("value", "");
						}
					});
				},
			}
		});
	</script>
	<script>
   <%-- document.getElementById("category").value = "<%=lb%>"; --%>
	</script>
</body>

</html>